<title>个人中心</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<script type="text/javascript" src="#(path)/assets/js/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="#(path)/assets/js/jquery.tmpl.min.js"></script> 
#@checkToken()
<style> 
	body{font-family:"Microsoft YaHei",Arial,Helvetica,sans-serif,"宋体";}
	li{list-style-type:none;}
</style>
<body bgcolor="#f4f5f9" style="margin:0px;color:#626262;">
<div  align="center" style="padding-bottom:60px;">
	<div style="width:100%;height:200px;background:#FFF;margin-top:5px;padding:5px 0 0 0;overflow:hidden;">
		<div>
			<div><a id="name"></a></div>
			<div style="font-size:30px;margin-top:5px;color:#33b29f"><a id="rate"></a></div>
			<div id="plus_rate" style="font-size:14px;margin-top:0px;color:#33b29f"></div>
			<div style="font-size:14px;margin-top:0px;">预期年化</div>
		</div>
		<div id="toutou" style="position:absolute;top:0px;right:0px;">
		</div>
		<div align="center">
			<div style="color:#999;width:50%;font-size:16px;float:left">投资期限 <a id="day_limit"></a></div>
			<div style="color:#999;width:50%;font-size:16px;float:left">起投资金 <a id="unit_amount"></a></div>
		</div>
		
		<div align="center" style="clear:both;border-top:1px solid #eee;margin-top:25px;padding-top:8px;">
			<div align="center" style="color:#666;width:49%;font-size:12px;float:left;height:50px;border-right:1px solid #eee">
				<div style="margin-top:10px;">投资本金(元)</div>  
				<div id="amount" style="font-size:20px;"></div> 
			</div>
			<div align="center" style="color:#666;width:49%;font-size:12px;float:left;height:50px;">
				<div style="margin-top:10px;">预期收益(元)</div>  
				<div  style="font-size:16px;color:#33b29f">
					<span id="target_amount" ></span> 
					<span id="target_jxq_amount"></span>  
					<span id="target_plus_amount"></span>
				</div> 
			</div>
		</div>
		
	</div>
	
	<div align="center" style="width:100%;height:135px;background:#FFF;margin-top:5px;padding:5px 0 0 0;">
		<div align="left" style="width:80%;">
			<table style="border-collapse:collapse;line-height:24px;font-size:14px;width:100%;">
				<tr>
					<td align="right" style="width:25%;">还款方式</td>
					<td style="width:75%;"><a id="repay_type" style="margin-left:20px;"></a></td>
				</tr>
				<tr>
					<td align="right" style="width:25%;">投资时间</td>
					<td style="width:75%;"><a id="create_time" style="margin-left:20px;"></a></td>
				</tr>

				<tr>
					<td align="right" style="width:25%;">起息时间</td>
					<td style="width:75%;"><a id="invest_start_time" style="margin-left:20px;"></a></td>
				</tr>

				<tr>
					<td align="right" style="width:25%;">还款时间</td>
					<td style="width:75%;"><a id="invest_end_time" style="margin-left:20px;"></a></td>
				</tr>
				<tr style="border-bottom:0px;">
					<td align="right" style="width:25%;">借款状态</td>
					<td style="width:75%;"><a id="status" style="margin-left:20px;"></a></td>
				</tr>
			</table>
		</div>
	</div>
	<div id="hetong" align="center" style="background:#FFF;height:50px;line-height:50px;border-top:1px solid #eee;color:#666">
		点击查看购买合同
	</div>
</div>
<script>
$(document).ready(function(){
	var id = GetRequest()["id"];
	console.log(id);
	var url ="#(path)/trade/myDetail?token=#(session.token??)&id="+id;
	$.getJSON(url, function(data) {
		var datainfo = data.data.item;
		console.log(datainfo);
		$("#name").html(datainfo.name);
		$("#rate").html(datainfo.rate + "%");
		$("#plus_rate").html("+"+datainfo.plus_rate + "%");
		$("#day_limit").html(datainfo.day_limit + "天");
		$("#amount").html(datainfo.amount);
		$("#unit_amount").html(datainfo.unit_amount + "元");
		$("#target_amount").html(datainfo.target_amount);
		if(datainfo.target_jxq_amount != "0.00"){
			$("#target_jxq_amount").html("+" + datainfo.target_jxq_amount);
		}
		if(datainfo.target_plus_amount != "0.00"){
			$("#target_plus_amount").html("+" + datainfo.target_plus_amount);
		}
		if(datainfo.repay_type == "all"){
			$("#repay_type").html("一次还本付息");
		}else if(datainfo.repay_type == "interest"){
			$("#repay_type").html( "按期付息到期还本");
		}else if(datainfo.repay_type == "pinciple"){
			$("#repay_type").html("等额本息");
		}else if(datainfo.repay_type == "amount"){
			$("#repay_type").html("等额本金");
		}
		$("#invest_end_time").html(datainfo.invest_end_time);
		$("#create_time").html(datainfo.create_time);
		$("#invest_start_time").html(datainfo.invest_start_time);
		if(datainfo.status == "repaying"){
			$("#status").html("还款中");
		}else if(datainfo.status == "trading"){
			$("#status").html("投资中");
			$("#invest_start_time").html("项目成立日");
			$("#invest_end_time").html("等待满标");
		}else if(datainfo.status == "finish"){
			$("#status").html("已还款");
		}
		$("#hetong").click(function(){
			window.location.href=datainfo.contract;
		});
	});
	
	function GetRequest() {   
	   var url = location.search; //获取url中"?"符后的字串  
	   var theRequest = new Object();  
	   if (url.indexOf("?") != -1) {  
		  var str = url.substr(1);  
		  strs = str.split("&");  
		  for(var i = 0; i < strs.length; i ++) {  
			 theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);  
		  }  
	   }  
	   return theRequest;  
	}  
	
});
</script>
	
	
	

	
</body>